package com.lck.main.game;

import com.lck.main.view.GamePanel;

import java.awt.*;

public class Pao extends Chess{
    public Pao(int player, Point p) {
        super("pao", player, p);
    }

    public Pao(int player, int px) {
        this(player, new Point(px,3));
    }

    @Override
    public boolean isAbleMoved(Point tp, GamePanel gamePanel) {
        Chess c = gamePanel.getChessByP(tp);
        if (c != null){
            //有棋子
            if (c.getPlayer()!=this.player){
                //吃子
                return line(tp) > 1 && getCount(tp,gamePanel) == 1;
            }
        } else {
            //移动
            return line(tp) > 1 && getCount(tp,gamePanel) == 0;
        }
        return false;
    }
}
